<template>
  <div class="nots">
		<div v-if="is_right == 1">
			<img src="https://img.wifenxiao.com/h5-wfx/images/user/verify_success.png" alt="">
			<p class="title">核销成功</p>
      <van-button  class="jump" @click="JumpName('mycoupon')" color="#F30C23" plain hairline round type="primary">点击返回优惠券列表</van-button>
		</div>
    <div v-else-if="is_right == 0">
			<img src="https://img.wifenxiao.com/h5-wfx/images/user/verify_fail.png" alt="">
			<p class="title">核销失败，{{message}}</p>
      <van-button  class="jump" @click="JumpName('mycoupon')" color="#F30C23" plain hairline round type="primary">点击返回优惠券列表</van-button>
		</div>
    <div v-else>
			<img src="https://img.wifenxiao.com/h5-wfx/images/user/verify_fail.png" alt="">
			<p class="title">核销中...</p>
		</div>
	</div>
</template>

<script>
import Vue from 'vue'
import { verifyCouponResult } from '@/api/user/member/memberApi'
export default Vue.extend({
  data() {
    return {
      is_right: -1,
      message: ''
    }
  },
  methods: {
    JumpName(name, data) {
        wx.redirectTo({
          url: `/user/pages/mycoupon/index?type=jump&targeturl=${encodeURIComponent('/mycoupon')}`
        })
    
    },
    init(id) {
      this.$loadingWrap.show()
      setTimeout(() => {
        this.$loadingWrap.close()
      }, 10000)
      verifyCouponResult({ verify_coupon_code: id }).then(res => {
        this.$loadingWrap.close()
        if (res.status == 1) {
          this.is_right = 1
            wx.setNavigationBarTitle({
              title: '核销成功'
            })
        } else {
          this.is_right = 0
          this.message = res.msg
            wx.setNavigationBarTitle({
              title: '核销失败'
            })
          this.$Error(res.msg)
        }
      })
    }
  },
  created() {
    this.query = this.$route.query
    // if (this.$route.query.pid) {
      this.init(this.query.verify_coupon_code)
    // }
  }
})
</script>

<style lang="scss">
.nots{
  >div{
    margin-top: 300px;
    text-align: center;
    img{
      width: 204px;
    }
    .title{
      font-size: 28px;
      color: #999999;
      line-height: 40px;
      margin: 26px 0 60px;
    }
    .jump{
      padding: 0 20px;
      height: 64px;
      font-size: 24px;
    }
  }
}
</style>